home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / CustomSolutionWizard_Files / ProjectShells / VBShellDlg.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-03-08  |  6.9 KB  |  198 lines

  1. VERSION 5.00
  2. Begin VB.Form VBShellDlg 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Custom Solution Wizard Sample"
  5.    ClientHeight    =   4875
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   4980
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   4875
  13.    ScaleWidth      =   4980
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.CheckBox chkResetNetwork 
  16.       Caption         =   "Reset Network Before Training"
  17.       Height          =   255
  18.       Left            =   480
  19.       TabIndex        =   4
  20.       Top             =   960
  21.       Width           =   2655
  22.    End
  23.    Begin VB.CommandButton cmdTrainNetwork 
  24.       Caption         =   "Train Network"
  25.       Height          =   375
  26.       Left            =   240
  27.       TabIndex        =   2
  28.       Top             =   480
  29.       Width           =   1815
  30.    End
  31.    Begin VB.CommandButton cmdClose 
  32.       Caption         =   "Close"
  33.       Height          =   375
  34.       Left            =   1920
  35.       TabIndex        =   1
  36.       Top             =   4320
  37.       Width           =   1215
  38.    End
  39.    Begin VB.CommandButton cmdGetNetworkOutput 
  40.       Caption         =   "Get Network Output"
  41.       Height          =   375
  42.       Left            =   240
  43.       TabIndex        =   0
  44.       Top             =   1440
  45.       Width           =   1815
  46.    End
  47.    Begin VB.Frame Frame1 
  48.       Caption         =   "Press the buttons to run the sample functions"
  49.       Height          =   1215
  50.       Left            =   120
  51.       TabIndex        =   5
  52.       Top             =   120
  53.       Width           =   4695
  54.       Begin VB.TextBox txtTrainNetwork 
  55.          Height          =   375
  56.          Left            =   2160
  57.          Locked          =   -1  'True
  58.          TabIndex        =   6
  59.          Text            =   "Not Tested."
  60.          Top             =   360
  61.          Width           =   2415
  62.       End
  63.    End
  64.    Begin VB.Frame Frame2 
  65.       Height          =   2415
  66.       Left            =   120
  67.       TabIndex        =   7
  68.       Top             =   1200
  69.       Width           =   4695
  70.       Begin VB.TextBox txtNetworkOutput 
  71.          BeginProperty Font 
  72.             Name            =   "Courier New"
  73.             Size            =   9.75
  74.             Charset         =   0
  75.             Weight          =   400
  76.             Underline       =   0   'False
  77.             Italic          =   0   'False
  78.             Strikethrough   =   0   'False
  79.          EndProperty
  80.          Height          =   1575
  81.          Left            =   120
  82.          Locked          =   -1  'True
  83.          MultiLine       =   -1  'True
  84.          ScrollBars      =   3  'Both
  85.          TabIndex        =   8
  86.          Text            =   "VBShellDlg.frx":0000
  87.          Top             =   720
  88.          Width           =   4455
  89.       End
  90.    End
  91.    Begin VB.Label Label1 
  92.       Alignment       =   2  'Center
  93.       BorderStyle     =   1  'Fixed Single
  94.       Caption         =   "The sample functions associated with these buttons have been modified to work with your training data."
  95.       Height          =   495
  96.       Left            =   480
  97.       TabIndex        =   3
  98.       Top             =   3720
  99.       Width           =   4095
  100.    End
  101. Attribute VB_Name = "VBShellDlg"
  102. Attribute VB_GlobalNameSpace = False
  103. Attribute VB_Creatable = False
  104. Attribute VB_PredeclaredId = True
  105. Attribute VB_Exposed = False
  106. Option Explicit
  107. Private Sub cmdClose_Click()
  108.     Unload Me
  109. End Sub
  110. Private Sub Form_Load()
  111.     resetNetwork = True
  112.     chkResetNetwork.Value = vbChecked
  113.     If RECALL_ONLY_NETWORK = True Then
  114.         txtTrainNetwork.Text = "Recall Network Only."
  115.         cmdTrainNetwork.Enabled = False
  116.         chkResetNetwork.Enabled = False
  117.     Else
  118.         txtTrainNetwork.Text = "Not tested."
  119.     End If
  120.     txtNetworkOutput.Text = "Not tested."
  121. End Sub
  122. Private Sub cmdGetNetworkOutput_Click()
  123.     'Get the network response as an array of outputs
  124.     Dim networkResponse As Variant
  125.     networkResponse = GetNetworkResponse
  126.     'Clear contents of the list box
  127.     txtNetworkOutput.Text = ""
  128.     'Get/Create the column labels for the output data
  129.     Dim outputLabelsArray As Variant
  130.     Dim i As Long
  131.     If CheckIfFileOnFileSystem(DATA_PATH & "\", DESIRED_FILE_NAME) = True Then
  132.         Dim outputLabels As String
  133.         Open DATA_PATH & "\" & DESIRED_FILE_NAME For Input As #1
  134.             Line Input #1, outputLabels
  135.         Close #1
  136.         outputLabelsArray = Split(outputLabels, Chr(9))
  137.     Else
  138.         ReDim outputLabelsArray(LBound(networkResponse, 2) To UBound(networkResponse, 2))
  139.         For i = LBound(outputLabelsArray) To UBound(outputLabelsArray)
  140.             outputLabelsArray(i) = "Output#" & i + 1
  141.         Next i
  142.     End If
  143.     Dim numberOfTrailingSpaces As Integer
  144.     Dim outStr As String
  145.     outStr = "Exemplar#"
  146.     For i = LBound(outputLabelsArray) To UBound(outputLabelsArray)
  147.         numberOfTrailingSpaces = 9 - Len(outputLabelsArray(i))
  148.         If (numberOfTrailingSpaces > 0) Then
  149.             outStr = outStr & Chr(9) & outputLabelsArray(i) & Space(numberOfTrailingSpaces)
  150.         Else
  151.             outStr = outStr & Chr(9) & Left(outputLabelsArray(i), 9)
  152.         End If
  153.     Next i
  154.     outStr = outStr & vbCrLf
  155.     'Prepare output data for display in text box. Limit to 1000 rows.
  156.     Dim j As Long
  157.     Dim maxRows As Long
  158.     maxRows = IIf(UBound(networkResponse, 1) > 1000, 1000, UBound(networkResponse, 1))
  159.     For i = LBound(networkResponse, 1) To UBound(networkResponse, 1)
  160.         outStr = outStr & Format(i + 1, "00000") & "    "
  161.         For j = LBound(networkResponse, 2) To UBound(networkResponse, 2)
  162.             outStr = outStr & Chr(9) & Format(networkResponse(i, j), "0.0000000")
  163.         Next j
  164.         outStr = outStr & vbCrLf
  165.     Next i
  166.     'Display output data in text box
  167.     txtNetworkOutput.Text = outStr
  168. End Sub
  169. Private Sub chkResetNetwork_Click()
  170.     If chkResetNetwork.Value = vbChecked Then
  171.         resetNetwork = True
  172.     Else
  173.         resetNetwork = False
  174.     End If
  175. End Sub
  176. Private Sub cmdTrainNetwork_Click()
  177.     txtTrainNetwork.Text = "Training..."
  178.     txtTrainNetwork.Refresh
  179.     Dim trainingBestCost As Variant
  180.     trainingBestCost = TrainNetwork
  181.     txtTrainNetwork.Text = "Best Cost = " & trainingBestCost
  182. End Sub
  183. Function CheckIfFileOnFileSystem(filePath As String, fileName As String) As Boolean
  184.     'Determine if a file with the given fileName exists in the given filePath
  185.     On Error GoTo ErrorHandler
  186.     Dim filePathName As String
  187.     filePathName = filePath & fileName
  188.     If StrComp(Dir(filePathName, vbNormal), fileName, vbTextCompare) <> 0 Then
  189.         CheckIfFileOnFileSystem = False
  190.     Else
  191.         CheckIfFileOnFileSystem = True
  192.     End If
  193.     On Error GoTo 0
  194.     Exit Function
  195. ErrorHandler:
  196.     CheckIfFileOnFileSystem = False
  197. End Function
  198.